#include<stdio.h>
#include<conio.h>
#include<math.h>
#define MAX 100
//ham nhap mang
void nhapmang(int a[], int n){
	printf("nhap mang: ");
	for(int i=0; i<n; i++){
		printf("\n\ta[%d]= ",i);
		scanf("%d",&a[i]);
	}
}
//ham xuat mang
void xuatmang(int a[], int n){
	printf("\n mang vua nhap vao la: ");
	for(int i=0; i<n; i++){
		printf("\t%d",a[i]);
	}
}
int tongbp(int a[], int n){
	int sum = 0;
	for(int i=0; i<n; i++){
		if(a[i]<0)
	sum = sum + a[i]*a[i];
	}
	return sum;
}
int main(){
	int a[MAX], n;
	printf("\n nhap vao so phan tu cua mang: ");
	scanf("%d",&n);
	nhapmang(a,n);
	xuatmang(a,n);
	int sum = tongbp(a,n);
	printf("\n");
	printf("\n tong can tim la:    %d",sum);
	getch();
}
